package com.ht.safe.entity;

import org.hibernate.annotations.Index;
import org.hibernate.annotations.Type;
import org.springframework.data.jpa.domain.AbstractPersistable;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * 通行人员基本信息
 * todo: 认证信息过期后的处理方式
 */
@Entity
@Table(name="T_Member")
public class Member extends AbstractPersistable<Integer> {


    @Column(nullable=false)
    @Index(name="idx_member_name")
    private String name;
    private String gender;// 性别
    private String department;// 部门
    private String job;// 职务
    private String email;
    private String address;
    private String telephone;   // 办公电话
    private String mobilephone; // 移动电话

    /**
     * 员工编号
     */
    @Column(name = "member_code")
    private String memberCode;

    /**
     * 人组信息
     */
    @ManyToOne(fetch=FetchType.EAGER)
    @JoinColumn(name="member_group_id")
    private MemberGroup memberGroup;

//    @OneToOne(cascade=CascadeType.ALL)
//    @MapsId
//    private Credential credential;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "member")
    private List<Credential> credentialList;

	public Member() {
	}

	public Member(Integer id) {
		this.setId(id);
	}

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public String getDepartment() {
        return department;
    }

    public void setDepartment(String department) {
        this.department = department;
    }

    public String getJob() {
        return job;
    }

    public void setJob(String job) {
        this.job = job;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getTelephone() {
        return telephone;
    }

    public void setTelephone(String telephone) {
        this.telephone = telephone;
    }

    public String getMobilephone() {
        return mobilephone;
    }

    public void setMobilephone(String mobilephone) {
        this.mobilephone = mobilephone;
    }

    public String getMemberCode() {
        return memberCode;
    }

    public void setMemberCode(String memberCode) {
        this.memberCode = memberCode;
    }

    public MemberGroup getMemberGroup() {
        return memberGroup;
    }

    public void setMemberGroup(MemberGroup memberGroup) {
        this.memberGroup = memberGroup;
    }

    public List<Credential> getCredentialList() {
        return credentialList;
    }

    public void setCredentialList(List<Credential> credentialList) {
        this.credentialList = credentialList;
    }
}
